var Int = {
	num: 0,
	init: function(footer){
		footer && $("body").append(Init.getFootHtml);//是否需要页脚
		this.eventInit();
	},
	dataInit: function(){

	},
	eventInit: function(){
		$("#wrapper").height($(window).height()-$("body>header").height()-$("body>footer").height());
		$(function(){
			refresher.init({//初始化下拉刷新
				id:"wrapper",
				pullDownAction: Int.refresh,
				pullUpAction: Int.load
			});
		});
		$(".rightBtn").on("click", function(){
			Main.jump('int_comment_add.html');
		});
		$(".int_list").on("touchend", ".heartEvt",function(){
			$(this).find(".int_ico_heart").toggleClass("sel");
		});
		$(".int_list").on("touchend", ".commentEvt",function(){
			Main.jump('int_comment_deail.html');
		});
	},
	load: function(){
		setTimeout(function () {
			var html = '';
			for (i=0; i<2; i++) {
				html += Int.getSinHtml();
			}
			$("#intList").append(html);
			myScroll.refresh();
		}, 800);
	},
	refresh: function(){
		setTimeout(function(){
			myScroll.refresh();
		},800);
	},
	getSinHtml: function(){
		Int.num++;
		var html = 	'<li class="int_sin">' + 
					'	<div class="ub sin_top">' + 
					'		<div class="sin_top_img"><img src="../dist/images/banner.png"></div>' + 
					'		<div class="ub ub-f1 ub-ver ub-pc">' + 
					'			<p class="sin_top_name">莫奈' + Int.num + '</p>' + 
					'			<div class="ub sin_top_des">' + 
					'				<p>26分钟前</p>' + 
					'				<em class="im_int"></em>' + 
					'				<p>上海</p>' + 
					'			</div>' + 
					'		</div>' + 
					'	</div>' + 
					'	<div class="sin_mid">修冰箱的师傅是个帅哥，好希望下次还看到他，还留着他手机号了</div>' + 
					'	<div class="ub sin_btm">' + 
					'		<div class="ub ub-f1 ub-pc ub-ac heartEvt">' + 
					'			<em class="im_int int_ico_heart"></em>' + 
					'			<p>10</p>' + 
					'		</div>' + 
					'		<div class="ub ub-f1 ub-pc ub-ac commentEvt">' + 
					'			<em class="im_int int_ico_talk"></em>' + 
					'			<p>5</p>' + 
					'		</div>' + 
					'	</div>' + 
					'</li>';
		return html;			
	},
	comDetailInit: function(){
		$(".int_com_list").height($(window).outerHeight() - $("header").outerHeight() - $(".int_sin").outerHeight() - $("footer").outerHeight());
		// $(".comText").focus(function(){
		// 	$(".com_fot").addClass("pa");
		// }).blur(function(){
		// 	$(".com_fot").removeClass("pa");
		// });
		$(".fot_btn").click(function(){
			var text = $(".comText").val();
			if (!text) return;

			var test = {name: '王大锤', time: Main.offsetDate(new Date()), desc: text}//模拟数据
			var html = Int.getSinDetailHtml(test.name,test.time,test.desc);
			$(".int_com_list").prepend(html);
			$(".comText").val('');
			$(".int_com_list").stop().animate({scrollTop: 0}, 500);
		});
	},
	getSinDetailHtml: function(name, time, desc){
		var html = 	'<div class="int_com_sin">' + 
					'	<div class="ub sin_top">' + 
					'		<div class="sin_top_img"><img src="../dist/images/banner.png"></div>' + 
					'		<div class="ub ub-f1 ub-ver ub-pc">' + 
					'			<div class="ub ub-ac com_sin_des">' + 
					'				<p>' + name + '</p>' + 
					'				<div class="ub-f1 tx-r">' + time + '</div>' + 
					'			</div>' + 
					'			<p class="com_sin_desc">' + desc + '</p>' + 
					'		</div>' + 
					'	</div>' + 
					'</div>';
		return html;
	},
	comAddInit: function(){
		$(".add_desc>textarea").change(function(){
			var len = $(this).val().length;
			$(".add_text_count").text(len);
		});
		$(".add_sin_img").on("click", function(){
			$(".add_img_list").prepend('<li class="im_addImg ub-img-bg add_sin_img" style="background-image:url(../dist/images/banner.png)"></li>');
		});
		$(".rightBtn").on("click", function(){
			var desc = $(".add_desc>textarea").val();
			if (!desc) return;
			Main.jump('int.html?tab=int');
		});
	}
}




